package com.jqutil.jqutil.cy;


import com.jqutil.jqutil.cy.entity.ReadData;
import com.jqutil.jqutil.cy.io.Read;
import com.jqutil.jqutil.cy.io.Write;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: chenyun
 * @Date: 2021/09/07/15:00
 * @Description:
 */

//主启动类
public class Start {

    public static void start(File file1) {
//        URL url = Start.class.getProtectionDomain().getCodeSource().getLocation();
        String filePath = file1.getAbsolutePath();


        System.out.println("path2:" + filePath);
        List<ReadData> readDataList = Read.read(filePath);
        readDataList.forEach(System.out::println);
//        String str= filePath.substring(0,filePath.lastIndexOf('\\'))+"\\1234.xlsx";


//        String str= "C:\\Users\\25079\\Desktop\\工作\\广西\\课表\\12345.xls";
//        System.out.println("输出目录"+str);
//        Write.write(readDataList, str);


//
//        String path = "C:\\Users\\cy\\Desktop\\新建文件夹\\2021-2022学年第1学期总课表(1).xls";
//        // 读取指定路径excle表，并转换格式
//        List<ReadData> readDataList = Read.read(path);
//        // 将转换格式后的表数据写入新excle表
//        System.out.println(path);
        Write.write(readDataList,filePath);

    }

    public static ArrayList<String> queryFilePath(String filePath) {
        ArrayList<String> es = new ArrayList<>();
        File f = new File(filePath);
        File[] ts = f.listFiles();
        File[] fs = f.listFiles();
        for (int i = 0; i < fs.length; i++) {
            if (ts[i].isFile()) {
                es.add(ts[i].toString());
            }
        }
        return es;
    }

}
